package design.p15_observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: Java
 * @description:
 * @author: zxf
 * @create: 2021-06-19 22:58
 **/
public abstract class AbstractSubject implements Subject{

    private List<Observer> list = new ArrayList<>();

    @Override
    public void add(Observer observer) {
        list.add(observer);
    }

    @Override
    public void del(Observer observer) {
        list.remove(observer);
    }

    @Override
    public void notifyObservers() {
        for (Observer o : list) o.update();
    }

}

